//2009/08/23 02:30:46
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class AzimuthMonitoring
{
public:
    int getAzimuth(vector <string> instr)
    {
        int ret = 0;
        for (int i=0; i<instr.size(); i++)
        {
            if (instr[i] == "LEFT")
                ret = ((ret - 90) % 360 + 360) % 360;
            else if (instr[i] == "RIGHT")
                ret = ((ret + 90) % 360 + 360) % 360;
            else if (instr[i] == "TURN AROUND")
                ret = ((ret + 180) % 360 + 360) % 360;
			else if(instr[i] == "HALT")
				break;
			else
			{
				stringstream s(instr[i]);
				string str;
				int num;
				s >> str >> num;
				if(str == "LEFT") ret = ((ret - num) % 360 + 360) % 360;
				else if(str == "RIGHT") ret = ((ret + num) % 360 + 360) % 360;
			}
        }
		return ret;
    }
};
